Skip to main content

Cancel shipment

In this section, you will find the explanation of how to cancel a shipment.

Cancel shipment request

To cancel a shipment, you need to send a POST request to the endpoint /api/Carriers/[CARRIER_ID]/cancelShipment/:trackingNumber with the following body:

Request body
{
"cancelReason": "string",
"destroyPackage": "boolean",
"returnToSender": "boolean"
}
FieldTypeFormatDescription
cancelReasonOPTIONALstringThe reason for the cancellation
destroyPackageOPTIONALbooleanWhether the package should be destroyed
returnToSenderOPTIONALbooleanWhether the package should be returned to the sender
Important

Shipments maybe canceled if they are in the ADDED state else they are charged.

An example of a request:

curl --location 'https://alphadev-api.peddler.com/api/Carriers/[CARRIER_ID]/cancelShipment/P123456789012345678' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <bearer-token-here>' \
--data '{
"cancelReason": "Customer requested to receive a new variant"
}'

Cancel shipment response

A standard response will be a 200 status code with the following body:

Response body with 200 status
{
"status": "<string>",
"count": "<number>"
}
FieldTypeDescription
statusstringThe status of the cancellation
countnumberThe number of shipments canceled

An example response body:

Response body example
{
"status": "SUCCESS",
"count": 1
}

The response will be a 404 status code with the following body if the tracking number is not valid or doesn't exist:

Response body with 404 status
{
"error": {
"statusCode": 404,
"name": "tracking-number-not-found",
"message": "TRACKING NUMBER NOT FOUND"
}
}
FieldTypeDescription
statusCodestringThe status of the cancellation
namestringThe details of the cancellation
messagestringThe message of the cancellation
Important

The shipment cannot be cancel if it is in the DELIVERED or OUT_FOR_DELIVERY state. In such a case, you will receive the following as response:

Response body with 422 status
{
"error": {
"statusCode": 422,
"name": "shipment-status-does-not-allow-cancelation",
"message": "SHIPMENT STATUS DOES NOT ALLOW CANCELATION"
}
}